﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.EntityFrameworkCore;

namespace EFEntity
{
    public class MyDbContext : DbContext
    {
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            optionsBuilder.UseSqlServer("Data Source = (local); Initial Catalog = jieyexm1; Persist Security Info = True; User ID = sa; Password = 1970156823");
        }
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            var etest = modelBuilder.Entity<EFconfig_file_first_kind>();
            etest.ToTable("config_file_first_kind");

            var etest1 = modelBuilder.Entity<EFconfig_file_second_kind>();
            etest1.ToTable("config_file_second_kind");
            //etest1.HasKey).WithMany().IsRequired().HasForeignKey(e => e.AuthorId);
            var etest2 = modelBuilder.Entity<Econfig_file_third_kind>();
            etest2.ToTable("config_file_third_kind");

            var etest3 = modelBuilder.Entity<Esalary_standard_details>();
            etest3.ToTable("salary_standard_details");//112
            //salary_standard_details

            var etest4 = modelBuilder.Entity<Econfig_public_char>();
            etest4.ToTable("config_public_char");
            var etest5 = modelBuilder.Entity<Econfig_major_kind>();
            etest5.ToTable("config_major_kind");//213
            var ecomfig = modelBuilder.Entity<EConfig_major>();
            ecomfig.ToTable("Config_major");
            ecomfig.HasKey(e => e.Id);

            //薪酬标准基本信息表    
            var salary2 = modelBuilder.Entity<Esalary_standard>();
            salary2.ToTable("salary_standard");
            //用户表
            var user = modelBuilder.Entity<Euser>();
            user.ToTable("user");
        }

        public DbSet<EFconfig_file_first_kind> first_kind { get; set; }
        public DbSet<EFconfig_file_second_kind> second_kind { get; set; }
        public DbSet<Econfig_file_third_kind> econfig_File_Third_Kinds { get; set; }
        public DbSet<Esalary_standard_details> alary { get; set; }
        public DbSet<Econfig_public_char> Tests { get; set; }
        public DbSet<Econfig_major_kind> Configs { get; set; }
        public DbSet<EConfig_major> Econfig { get; set; }
        //薪酬标准基本信息表    
        public DbSet<Esalary_standard> Esalary2 { get; set; }

        //用户表
        public DbSet<Euser> Euse { get; set; }
    }
}
